﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using You.Niao.User.Model;
using System.Reflection;
using You.Niao.User.IDAL;
using System.Data.SqlClient;
using DBUtility;
using Common.Base;
using You.Niao.Pic.Model;
using System.Data;
using System.Data.SqlClient;

namespace You.Niao.User.DAL
{
    public  class PrLitterDAL:SqlConn,IPrletter
    {
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(PrLetter model)
       {
           StringBuilder strSql = new StringBuilder();
           strSql.Append("insert into Prletter(");
           strSql.Append("SenderUserID,Sender,InceptUserID,Incept,Conversation");
           strSql.Append(") values (");
           strSql.Append("@SenderUserID,@Sender,@InceptUserID,@Incept,@Conversation");
           strSql.Append(") ");
           strSql.Append(";select @@IDENTITY");
           SqlParameter[] parameters = {
			            new SqlParameter("@SenderUserID", SqlDbType.Int,4) ,            
                        new SqlParameter("@Sender", SqlDbType.VarChar,16) ,            
                        new SqlParameter("@InceptUserID", SqlDbType.Int,4) ,            
                        new SqlParameter("@Incept", SqlDbType.VarChar,16) ,            
                        new SqlParameter("@Conversation", SqlDbType.NVarChar,100)         
            };

           parameters[0].Value = model.SenderUserID;
           parameters[1].Value = model.Sender;
           parameters[2].Value = model.InceptUserID;
           parameters[3].Value = model.Incept;
           parameters[4].Value = model.Conversation;

           object obj = DbHelperSQL.GetSingle(UserConn,strSql.ToString(), parameters);
           if (obj == null)
           {
               return 0;
           }
           else
           {
               return Convert.ToInt32(obj);
           }
       }
    }
}
